const fib = (n) => {
  if (n < 2) {
    return n
  }
  const mod = 1000000007

  let q = 0
  let r = 1
  for (let i = 2; i < n + 1; i++) {
    let t = q
    q = r
    r = (t + q) % mod
  }
  return r
}
console.log(fib(5));